import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RoleQuery, RolePageResult, RoleForm,RoleItemAdd,RoleItem,RoleDeleteRequest,RoleItemUpdate} from './types';



export function getAllRoles(){
    return request({
        url:'/api/identity/roles/all',
        method:'get'
    })
}


/**
 * 获取角色分页数据
 *
 * @param queryParams
 */
export function getRolePage(
  queryParams?: RoleQuery
): RolePageResult {
  return request({
    url:'/api/identity/roles',
    method: 'get',
    params: queryParams
  });
}

export function addRole(data:RoleItemAdd):RoleItem{
    return request({
      url:`/api/identity/roles`,
      method:'post',
      data:data
    });
}

export function deleteRole(data:RoleDeleteRequest):any{
  return request({
    url:`/api/identity/roles/${data.id}`,
    method:`delete`,
    }
  )
}

/**
 * 获取角色详情
 *
 * @param id
 */
export function getRole(id: string):RoleItem {
  return request({
    url: `/api/identity/roles/${id}`,
    method: 'get'
  });
}



/**
 * 更新角色
 *
 * @param id
 * @param data
 */
export function updateRole(id: string, data: RoleItemUpdate) {
  return request({
    url: `/api/identity/roles/${id}`,
    method: 'put',
    data: data
  });
}

/**
 * 批量删除角色，多个以英文逗号(,)分割
 *
 * @param ids
 */
export function deleteRoles(ids: string) {
  return request({
    url: '/api/v1/roles/' + ids,
    method: 'delete'
  });
}
